﻿/*
 * Erstellt mit SharpDevelop.
 * Benutzer: Kai Patrick
 * Datum: 20.03.2008
 * Zeit: 19:24
 * 
 * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
 */

using System;
using System.IO;
using System.Windows.Forms;

namespace Gamadus.Builder
{
	/// <summary>
	/// Description of DirectoryMgr.
	/// </summary>
	public class DirectoryMgr : Gamadus.Core.SingletonManager<DirectoryMgr>
	{
		string tempDir;
		public string TempDir
		{
			get
			{
				return tempDir;
			}
		}
		string dataDir;
		public string DataDir
		{
			get
			{
				return dataDir;
			}
		}
		string runDir;
		public string RunDir
		{
			get
			{
				return runDir;
			}
		}
		
		public void Init()
		{
			runDir = new FileInfo(Application.StartupPath).FullName;
			
			System.IO.Directory.SetCurrentDirectory(runDir);
			char dirSep = Path.DirectorySeparatorChar;

			tempDir = Path.Combine(Path.Combine(runDir, "Temp"),"Builder")+dirSep;
			dataDir = runDir+dirSep;
			runDir = runDir+dirSep;
			
			if(!Directory.Exists(tempDir))
				Directory.CreateDirectory(tempDir);
				
			Console.WriteLine("Using "+tempDir+" for temporary files");
			Console.WriteLine("Engine binary is located in "+runDir);
			Console.WriteLine("Other data is located in "+dataDir);
		}
		
		public void Clean()
		{
			Console.Write("Cleanup...");
			foreach(string f in Directory.GetFiles(tempDir))
			{
				File.Delete(f);
			}
			Directory.Delete(tempDir);
			Console.WriteLine("Done.");
		}
	}
}
